package com.alibaba.crs.ui;
import com.alibaba.crs.entity.MotorVehicle;
import com.alibaba.crs.service.MotorVehicleService;
import java.util.Scanner;
/**@author GuoBin Hao
 * @version V1.0
 * @createDate 2021-3-31
 * 汽车租赁管理类
 */
public class MotorVehicleManager {
    private static Scanner input = new Scanner(System.in);

    public static void appStart(){
        System.out.println("*************欢迎光临腾飞汽车租赁有限公司****************");
        System.out.println("\t1.轿车\t2.客车\t3.卡车");
        System.out.print("请选择您要租赁的汽车类型：");
        int choice = input.nextInt();
        int days = 0,seatNum = 0,load = 0;
        String brand = "",carType = "";
        switch (choice){
            case 1:
                System.out.print("请选择您要租赁的汽车品牌：1. 宝马    2.别克：");
                choice = input.nextInt();
                if(choice == 1){
                    brand = "宝马";
                    System.out.print("请选择您要租赁的汽车型号：1. X6    2.550i：");
                    choice = input.nextInt();
                    if(choice == 1){
                        carType = "X6";
                    }
                    else{
                        carType = "550i";
                    }
                }
                else if(choice == 2){
                    brand = "别克";
                    System.out.print("请选择您要租赁的汽车型号：1. 林荫大道    2.GL8：");
                    choice = input.nextInt();
                    carType = choice == 1 ? "林荫大道" : "GL8";
                }
                break;
            case 2:
                System.out.print("请选择您要租赁的汽车品牌：1. 金龙    2.金杯：");
                choice = input.nextInt();
                brand = choice == 1 ? "金龙" : "金杯";
                System.out.print("请选择您要租赁的汽车座位数：1. 16座    2.34座：");
                choice = input.nextInt();
                seatNum = choice == 1 ?  16 : 34;
                break;
            case 3:
                System.out.print("请选择您要租赁的汽车品牌：1. 一汽解放    2.重庆红岩：");
                choice = input.nextInt();
                brand = choice == 1 ? "一汽解放" : "重庆红岩";
                System.out.print("请选择您要租赁的汽车吨位：1. 1吨    2.2吨：");
                choice = input.nextInt();
                load = choice == 1 ?  1 : 2;
                break;
        }  // end switch
        System.out.print("请输入您要租赁的天数：");
        days = input.nextInt();
        MotorVehicle vehicle = MotorVehicleService.rentVehicle(brand, carType, seatNum, load);
        if(vehicle != null) {
            double totalPrice = vehicle.calcRent(days);
            System.out.println("分配给您的汽车车牌号是：" + vehicle.getLicenseNo());
            System.out.println("您需要支付的租赁费用是：" + totalPrice + "元");
        }
        else {
            System.err.println("根据您提供汽车信息没有找到您所需要汽车！");
        }
    }

    public static void main(String[] args) {
        //系统启动
        appStart();
        input.close();
    }
}
